/*

  MMetaverseSurface

  Copyright (c) 2009 Mary Jane Soft - Marlon J. Manrique
	
  http://www.maryjanesoft.com
  http://www.marlonj.com

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

  $Id$
	
*/

default
{
	// When the script is started 
	// open a Remote Channel to accept request from 
	// the MMetaverseSurface using XML-RPC
	state_entry()
	{
		llOpenRemoteDataChannel();
	}
 
	// Receive event associated with the remote channel 
	// type : The remote event 
	// channel : The channel number 
	// message_id : The message id 
	// sender : The sender id 
	// ival : The integer value 
	// sval : The string value  
	remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
	{
		// Channel Open event 
		if(type == REMOTE_DATA_CHANNEL)
		{
			// Show the channel id to associated with the object 
			llOwnerSay("Channel : " + (string) channel);
		}
		// A request is available 
		else if(type == REMOTE_DATA_REQUEST)
		{
			// Response with default data 
			llRemoteDataReply(channel,NULL_KEY,"",0);

			// Check request type 
			// REQUEST_MOVE = 1 
			if(ival == 1)
			{
				// Update the location of the object
				// Using the data in the format <x,y,z>
				llSetPos((vector) sval);
			}
			// REQUEST_ROTATE = 2
			else 
			{			
				// Rotate around Z axis the value specified 	
				llSetRot(llEuler2Rot(<0,0,(float) sval>));				
			}
		}
		else
		{
			// If not type is recognize show a error message 
			llOwnerSay("Error");
		}
	}
}
